﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="FillCartridgeBBB.Models" %>

<table>
        <tr>
          <%if (!ReferenceEquals(ViewData["Type"], "List"))
          {%>
            <th></th>
        <%}%>
            <th>
                Назва принтера
            </th>
            <th>
                Назва картриджа
            </th>
        </tr>

    <% foreach (var item in (IEnumerable<Printer>)ViewData.Eval("Printers"))
       { %>
    
        <tr>
        <%
            if (ReferenceEquals(ViewData["Type"], "Edit")) {%>
            <td>
                <%= Html.ActionLink("Edit", "Edit", new { id=item.PrinterId }) %> |
                <%= Html.ActionLink("Details", "Details", new { id=item.PrinterId })%> |
                <%= Html.ActionLink("Delete", "Delete", new { id=item.PrinterId },new { Onclick = "return confirm ('Ви впевнені?')"})%>
            </td>
            <%} else if (ReferenceEquals(ViewData["Type"], "Select")) {
            %>
            <td>
                  <%=
                  Html.CheckBox("PrinterId", (Model!=null) && ((Department)Model).Printers.Where(prt => prt.PrinterId == item.PrinterId).Count() > 0, new Dictionary<string, object> {{"Value", item.PrinterId}})
                  %>
                  </td>
                  <%}
            
          if (!Equals(ViewData["Type"], "List"))
          {%>
          <td>
                <%= Html.Encode(item.PrinterName) %>
            </td>
            <%
                }
          else
          {%>
          <td>
          <%=Html.ActionLink(item.PrinterName, "Details", "Printer",
                                                new {id = item.PrinterId}, null)%>
                                                              </td>
                                                              <%
          }%>
            <td>
                <%= Html.Encode(item.CartridgeName) %>
            </td>
        </tr>        
    
    <% } %>

    </table>